﻿namespace _3.装饰模式;


/// <summary>
/// 装饰类
/// </summary>
public class Finery : Person
{
    protected Person? component;

    public void Decorate(Person component)
    {
        this.component = component;
    }

    /// <summary>
    /// 实际调用的是父类Person的Show方法
    /// </summary>
    public override void Show()
    {
        if (component != null)
        {
            component.Show();
        }
    }
}

public class Tshirts : Finery
{
    //重写Show方法并在方法中调用父类show方法，下同
    public override void Show()
    {
        Console.Write("大T恤 ");
        base.Show();
    }
}

public class BigTrousers : Finery
{
    public override void Show()
    {
        Console.Write("垮裤 ");
        base.Show();
    }
}

public class Sneakers : Finery
{
    public override void Show()
    {
        Console.Write("破球鞋 ");
        base.Show();
    }
}

public class Suit : Finery
{
    public override void Show()
    {
        Console.Write("西装 ");
        base.Show();
    }
}

public class Tie : Finery
{
    public override void Show()
    {
        Console.Write("领带 ");
        base.Show();
    }
}

public class LeatherShoes : Finery
{
    public override void Show()
    {
        Console.Write("皮鞋 ");
        base.Show();
    }
}
